<template>
	<view class="commodity" :style=" 'flex-wrap:' + swap">
		<view class="commodity-item" v-for="(item, index) in dataList" :index="index" :style=" 'width: '+ itemW ">
			<img class="commodity-img" :src="item.imgUrl" :style=" 'height:' + bigH " alt="" />
			<view class="commodity-content">
				<text class="commodity-name">{{item.name}}</text>
				<view>
					<text class="pprice">￥{{item.pprice}}</text>
					<text class="oprice">￥{{item.oprice}}</text>
				</view>
				<text class="discount">{{item.discount}}折</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			dataList: Array,
			itemW: {
				type: String,
				default: "375rpx"
			},
			bigH: {
				type: String,
				default: "375rpx"
			},
			swap: {
				type: String,
				default: "wrap"
			}
		}
	}
</script>

<style scoped>
	.commodity {
		display: flex;
	}

	.commodity-item {
		padding-bottom: 20rpx;
	}

	.commodity-img {
		width: 100%;
	}

	.commodity-content {
		text-align: center;
	}

	.commodity-name {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		color: #333333;
		word-break: break-all;
		padding: 6rpx 20rpx;
		font-size: 32rpx;
	}

	.oprice {
		text-decoration: line-through;
		font-size: 24rpx;
		color: #999999;
		margin-left: 5rpx;
	}

	.discount {
		border-radius: 4rpx;
		border: 1rpx solid red;
		font-size: 25rpx;
		color: red;
	}
</style>